<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<?php
$attributes = array(
    'class' => 'control-label',
);
?>
<div class="span9">
    <h3><?php echo $titulo; ?></h3> 
    <?php echo get_message(); ?> 
    <?php echo form_open(); ?> 
    <div class="container-table">
        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-hover table-bordered" id="example">
            <thead>
                <tr>
                    <th>Fecha</th>
                    <th>Fecha del hecho</th>
                    <th>Tipo</th>
                    <th>Motivo</th>
                    <th>Médico</th>
                    <th>Asesores</th>
                    <th>Acciones</th>
                </tr>
            </thead>
            <tbody>
                <?php
                if (!empty($consultas)) {
                    $color = 'odd';
                    foreach ($consultas as $consulta) {
                        $color = ( $color == 'odd') ? 'even' : 'odd';
                        ?>
                        <tr class="<?php echo $color; ?>">
                            <td><?php echo database_to_normal_date($consulta->fecha); ?></td>
                            <td><?php echo database_to_normal_date($consulta->fechaActoMedico); ?></td>
                            <td><?php echo $consulta->tipo; ?></td>
                            <td><?php echo $consulta->motivo; ?></td>
                            <td><?php echo $consulta->matricula . ' - ' . $consulta->medico; ?></td>
                            <td>
                                <ul>
                                    <?php
                                    foreach ($consulta->asesores as $asesor) {
                                        ?>
                                        <li><?php echo $asesor->nombre . ' ' . $asesor->apellido; ?></li>
                                        <?php
                                    }
                                    ?>
                                </ul>
                            </td>
                            <td>
                                <a class="btn btn-small btn-info vincular" href="javascript:;" id="visto-<?php echo $consulta->id; ?>" dbid="<?php echo $consulta->id; ?>"><span class="icon-check"></span></a>
                            </td>
                        </tr>
                        <?php
                    }
                }
                ?>
            </tbody>
        </table>
    </div>
    <?php echo form_close(); ?>
</div>

<script type="text/javascript">
    $(".vincular").click(function(){
        var id = $(this).attr('dbid');
        $.ajax({
            type:"POST",
            url:"<?php echo 'vincular/'; ?>" + id,
            success: function(html){
                $("#visto-" + id).fadeOut('fast');
            }
        });
    });
</script>